using UnityEngine.Events;

namespace Light
{
    /// <summary>
    ///     ��û�м̳�mono����࿪��Я�̼���update����ʹ��
    /// </summary>
    public class MonoManager : SingletonMono<MonoManager>
    {
        private void Update()
        {
            updateEvent?.Invoke();
        }

        private void FixedUpdate()
        {
            fixedUpdateEvent?.Invoke();
        }

        private void LateUpdate()
        {
            lateUpdateEvent?.Invoke();
        }

        private event UnityAction updateEvent;
        private event UnityAction fixedUpdateEvent;
        private event UnityAction lateUpdateEvent;

        /// ����Update֡���¼�������
        public void AddUpdateListener(UnityAction updateFun)
        {
            updateEvent += updateFun;
        }

        /// �Ƴ�Update֡���¼�������
        public void RemoveUpdateListener(UnityAction updateFun)
        {
            updateEvent -= updateFun;
        }

        /// ����FixedUpdate֡���¼�������
        public void AddFixedUpdateListener(UnityAction updateFun)
        {
            fixedUpdateEvent += updateFun;
        }

        /// �Ƴ�FixedUpdate֡���¼�������
        public void RemoveFixedUpdateListener(UnityAction updateFun)
        {
            fixedUpdateEvent -= updateFun;
        }


        /// ����LateUpdate֡���¼�������
        public void AddLateUpdateListener(UnityAction updateFun)
        {
            lateUpdateEvent += updateFun;
        }

        /// �Ƴ�LateUpdate֡���¼�������
        public void RemoveLateUpdateListener(UnityAction updateFun)
        {
            lateUpdateEvent -= updateFun;
        }
    }
}